//
//  TYHUIDifine.h
//  OpenPractice
//
//  Created by tanyuehong on 6/7/18.
//  Copyright © 2018年  lijinghua. All rights reserved.
//

#ifndef TYHUIDifine_h
#define TYHUIDifine_h

#import "NSDate+Utilities.h"

#ifdef DEBUG
#define NSLog(format, ...) printf("\n[%s] %s [第%d行] %s\n", [[[NSDate date] stringWithFormat:@"YYYY-MM-dd hh:mm:ss:SSS"] UTF8String], __FUNCTION__, __LINE__, [[NSString stringWithFormat:format, ## __VA_ARGS__] UTF8String]);
#else
#define NSLog(format, ...)
#endif
//device
#define UI_SINGLELINE (((int)(100/(UI_SCREEN_SCALE)))/100.0)
#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
#define SYSTEM_VERSION_7_OR_GREATER (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
#define SYSTEM_VERSION_8_OR_GREATER (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
#define SYSTEM_VERSION_9_OR_GREATER (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0"))
#define SYSTEM_VERSION_10_OR_GREATER (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10.0"))
#define IS_RETINA  ([[UIScreen mainScreen] scale] != 1)
#define UI_SCREEN_SCALE ([[UIScreen mainScreen] scale])
#define UI_SCREEN_SIZE ([UIScreen mainScreen].bounds.size)
#define UI_SCREEN_SIZE_FOR_PORTRAIT CGRectMake(0, 0, MIN(UI_SCREEN_SIZE.width, UI_SCREEN_SIZE.height), MAX(UI_SCREEN_SIZE.width, UI_SCREEN_SIZE.height))
#define IOS_7_0 @"7.0"
#define IOS_8_0 @"8.0"
#define iPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(320*UI_SCREEN_SCALE, 480*UI_SCREEN_SCALE), [[UIScreen mainScreen] currentMode].size) : NO)

#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(320*UI_SCREEN_SCALE, 568*UI_SCREEN_SCALE), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(375*UI_SCREEN_SCALE, 667*UI_SCREEN_SCALE), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(414*UI_SCREEN_SCALE, 736*UI_SCREEN_SCALE), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhoneX     ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(375*UI_SCREEN_SCALE, 812*UI_SCREEN_SCALE), [[UIScreen mainScreen] currentMode].size) : NO)


#define kDeviceIsPad       (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define kDeviceIsPhone     (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IOS_11  ([[[UIDevice currentDevice] systemVersion] floatValue] >= 11.f)


// 判断是否刘海屏
#define kIsBangsScreen (IS_IOS_11 && kDeviceIsPhone && (MIN([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height) >= 375 && MAX([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height) >= 812))

//判断iPhoneX
#define kDeviceIsIphoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !kDeviceIsPad : NO)
//判断iPHoneXr
#define kDeviceIsIphoneXR ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? (CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) || CGSizeEqualToSize(CGSizeMake(750, 1624), [[UIScreen mainScreen] currentMode].size)) && !kDeviceIsPad : NO)
//判断iPhoneXs
#define kDeviceIsIphoneXS ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !kDeviceIsPad : NO)
//判断iPhoneXs Max
#define kDeviceIsIphoneXS_MAX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) && !kDeviceIsPad : NO)


//判断是否为全面屏
#define kDeviceIsFullScreen (kDeviceIsIphoneX == YES || kDeviceIsIphoneXR == YES || kDeviceIsIphoneXS == YES || kDeviceIsIphoneXS_MAX == YES || kIsBangsScreen || [[UIApplication sharedApplication] statusBarFrame].size.height>20)

//状态栏 从iOS 14开始，全面屏iPhone的状态栏高度不一定是44
#define kZDStatusBarHeight \
^(){\
NSInteger i = 0;\
if (@available(iOS 11.0, *)) {\
    if(kDeviceIsFullScreen){\
        UIWindow *window = [UIApplication.sharedApplication.windows firstObject];\
        i = window.safeAreaInsets.top;\
    }\
} else {\
    i = [UIApplication sharedApplication].statusBarFrame.size.height;\
}\
if(i <= 0){\
    i = (kDeviceIsFullScreen?44:20);\
}\
    return i;\
}()

//font
#define UI_NORMAL_FONT(fontSize) [UIFont systemFontOfSize:fontSize]
#define UI_HILIGHT_FONT(fontSize) [UIFont systemFontOfSize:fontSize]
#define UI_BOLD_FONT(fontSize) [UIFont boldSystemFontOfSize:fontSize]
#define kButtonTitleFont      [UIFont systemFontOfSize:14]
#define kItemTitleFont      [UIFont systemFontOfSize:15]


//Color
#define UI_COLOR(r,g,b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]
#define UI_COLOR_A(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]

#define kHistoryBtnColorNormal              kThemeBlueColor
#define kHistoryBtnBorderColorNormal        [UIColor colorWithHex:0x9bcefe]
#define kHistoryBtnBorderColorHighlight     [UIColor colorWithHex:0x176ccc]
#define kHistoryBtnTitleColorNormal         [UIColor colorWithHex:0xb0dcff]
#define kHistoryBtnTitleColorHighlight      [UIColor colorWithHex:0x176ccc]
#define kVoiceBtnTitleColorNormal           [UIColor whiteColor]
#define kVoiceBtnTitleColorHighlight        [UIColor colorWithHex:0x176ccc]

#define ControllerBackgroundColor           [UIColor colorWithHex:0xFAFAFA]
#define kSingleLineColor                    [UIColor colorWithHex:0xdddddd]
#define MoreBackgroundColor                 [UIColor colorWithHex:0xEEEEEE]
#define kSeparateViewBackgroundColor        [UIColor colorWithHex:0xF8F8F8]


#define kTextBarItemColorNormal  [UIColor colorWithHexString:@"666666"]
#define kTextBarItemColorHilight [UIColor colorWithHexString:@"bbbbbb"]
#define kTextFieldBackColor      [UIColor colorWithHexString:@"83d8ff"]
#define kTextFieldColor          [UIColor colorWithHexString:@"5eb1ff"]
#define kTextFieldBackLabelColor [UIColor colorWithHexString:@"003f9e"]
#define kPlaceHolderLabelColor   [UIColor colorWithHexString:@"007edd"]
#define kTextFieldBackHightColor [UIColor colorWithHexString:@"44b8fe"]
#define KTextFieldBackColor      [UIColor colorWithHexString:@"004ec4"]
#define kTextFieldTextColor      [UIColor colorWithHexString:@"ffffff"]
#define kTextFieldTextHightColor [UIColor colorWithHexString:@"48b9ff"]


#define kAccountTextFieldHintColor        [UIColor colorWithHexString:@"9ddbfb"]
#define kAccountLabelTextColor            [UIColor colorWithHexString:@"48a8f7"]
#define kAccountTextFieldCursorColor      [UIColor colorWithHexString:@"b9e4ff"]

#define kTYH333333TextColor               [UIColor colorWithHex:0x333333]
#define kTYH666666TextColor               [UIColor colorWithHex:0x666666]
#define kTYH999999TextColor               [UIColor colorWithHex:0x999999]


#define kOPBackgroundColor                [UIColor whiteColor]
#define kOPSeparateBackgroundColor        [UIColor colorWithHex:0xF8F8F8]


#define kTYHSingleLine          (2.0/[UIScreen mainScreen].scale)

#endif /* TYHUIDifine_h */
